package com.stive.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.stive.reggie.common.R;
import com.stive.reggie.entity.Orders;
import com.stive.reggie.service.OrderDetailService;
import com.stive.reggie.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author NULL
 * @version 1.0
 * @date 2023/8/11 19:24
 */

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderDetailController {

    @Autowired
    private OrderDetailService orderDetailService;

    @Autowired
    private OrdersService ordersService;

    @GetMapping("/userPage")
    public R<Page> page(int page, int pageSize) {
        return orderDetailService.pageOrderDetail(page, pageSize);
    }

    @PutMapping()
    public R<String> update(@RequestBody Orders orders) {
        Orders order = ordersService.getById(orders.getId());
        order.setStatus(orders.getStatus());
        ordersService.updateById(order);
        return R.success("操作成功");
    }
}
